import type {FC} from 'react'
import QuestionInputConf,{ QuestionInputPropsType } from "./QuestionInput/index.ts";
import QuestionTitleConf,{ QuestionTitlePropsType } from "./QuestionTitle/index.ts";
import QuestionParagraphConf,{ QuestionParagraphPropsType } from './QuestionParagraph/index.ts';
import QuestionInfoConf, { QuestionInfoPropsType } from './QuestionInfo/index.ts'
import QuestionTextareaConf, { QuestionTextareaPropsType } from './QuestionTextarea/index.ts'
import QuestionRadioConf,{QuestionRadioPropsType} from  './QuestionRadio/index.ts'
import QuestionCheckboxConf, {
    QuestionCheckboxPropsType,
    // QuestionCheckboxStatPropsType,
} from './QuestionCheckbox/index.ts'
import { title } from 'process';

// 每个组件的 prop type
export type ComponentPropsType = QuestionInputPropsType & 
QuestionTitlePropsType & 
QuestionParagraphPropsType & 
QuestionInfoPropsType & 
QuestionTextareaPropsType & 
QuestionRadioPropsType &
QuestionCheckboxPropsType

// 组件的配置
export type ComponentConfType = {
    title: string
    type: string
    Component: FC<ComponentPropsType>
    PropComponent: FC<ComponentPropsType>
    defaultProps: ComponentPropsType
}

// 全部的组件配置列表
const componentConfList: ComponentConfType[] = [
    QuestionInputConf,
    QuestionTitleConf,
    QuestionParagraphConf,
    QuestionInfoConf,
    QuestionTextareaConf,
    QuestionRadioConf,
    QuestionCheckboxConf
]

// 组件分组--一共7个
export const componentConfGroup = [
    {
        groupId:'textGroup',
        groupName: '文本显示',
        components:[QuestionTitleConf,QuestionParagraphConf,QuestionInfoConf]
    },
    {
        groupId:'inputGroup',
        groupName: '用户输入',
        components:[QuestionInputConf,QuestionTextareaConf]
    },
    {
        groupId:'chooseGroup',
        groupName: '用户选择',
        components:[QuestionRadioConf,QuestionCheckboxConf]
    }
]
export function getComponentConfByType(type: string){
    return componentConfList.find(c =>c.type === type)
}